#include<iostream>
#include<memory>


class Girl;

class Boy
{
public:

Boy(){std::cout<<"boy构造\n";}
~Boy()
{
    std::cout<<"boy析构\n";
}

void SetGirl(std::shared_ptr<Girl> &g)
{
    girlfriend = g;
}



private:
std::weak_ptr<Girl> girlfriend; 



};

class Girl
{
public:

Girl(){std::cout<<"girl构造\n";}
~Girl()
{
    std::cout<<"girl析构\n";
}

void SetBoy(std::shared_ptr<Boy> &b)
{
    boyfriend = b;
}


private:
std::weak_ptr<Boy> boyfriend; 



};


int main()
{
    std::shared_ptr<Boy> b = std::make_shared<Boy>();
    std::shared_ptr<Girl> g = std::make_shared<Girl>();

    b->SetGirl(g);
    g->SetBoy(b);
    
}